#!/bin/sh

python -m pip install -r requirements.txt
python -m pip install sphinx sphinx-rtd-theme
python -m pip install --pre git+git://github.com/willsimmons1465/jupyter-sphinx.git@issue-140#egg=jupyter-sphinx

cd manual/

ESCAPED_REQS=$(awk '{printf "%s%s",sep,$0; sep="\\\n"} END{print ""}' ../requirements.txt)
sed "s/REQUIREMENTS/$ESCAPED_REQS/" index-rst-template > index.rst

rm -rf build/
sphinx-build -b html . build

rm index.rst

cd ..

rm -rf docs/manual/
cp -r manual/build/ docs/manual
